package com.yanqu.road.server.manger.maidian;

import com.yanqu.road.entity.player.UserInfo;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.utils.date.DateHelper;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
 * 在线埋点
 */
public class OnLineLog {

    private static Logger logger = LogManager.getLogger(OnLineLog.class.getName());

    public static final String ONLINE_TIME = "online_time";

    /**
     * 在线时长
     */
    public static void markOnlineTime(GamePlayer player, int times, long online, long dateZeroTime){
        try{
            DefaultEventTraceAction traceAction = new DefaultEventTraceAction(ONLINE_TIME, player);
            traceAction.build("#time", DateHelper.getCurrentDateTimeString(dateZeroTime * 1000));
            traceAction.build("online_timenum", times);
            traceAction.build(ONLINE_TIME, online);
            traceAction.trace();
        }catch (Exception e){
            logger.error(" markOnlineTime ", e);
        }
    }

    /**
     * 在线时长
     */
    public static void markOnlineTime(UserInfo userInfo, int times, long online, long dateZeroTime){
        try{
            DefaultEventTraceAction traceAction = new DefaultEventTraceAction(ONLINE_TIME, userInfo);
            traceAction.build("#time", DateHelper.getCurrentDateTimeString(dateZeroTime * 1000));
            traceAction.build("online_timenum", times);
            traceAction.build(ONLINE_TIME, online);
            traceAction.trace();
        }catch (Exception e){
            logger.error(" markOnlineTime ", e);
        }
    }

}
